#include "CircQueue.h"

void initQueue(CircQueue& Q)
{
	Q.front = 0;
	Q.rear = 0;
}

bool queueEmpty(CircQueue& Q)
{
	return Q.front == Q.rear;
}

bool queueFull(CircQueue& Q)
{
	return (Q.rear + 1) % queSize == Q.front;
}

int queueSize(CircQueue& Q)
{
	return (Q.rear - Q.front + queSize) % queSize;
}

bool enQueue(CircQueue& Q, QElemType x)
{
	if (queueFull(Q))
	{
		return false;
	}
	Q.elem[Q.rear] = x;
	Q.rear = (Q.rear + 1) % queSize;
	return true;
}

bool deQueue(CircQueue& Q, QElemType& x)
{
	if (queueEmpty(Q))
	{
		return false;
	}
	x = Q.elem[Q.front];
	Q.front = (Q.front + 1) % queSize;
	return true;
}

bool getFront(CircQueue& Q, QElemType& x)
{
	if (queueEmpty(Q))
	{
		return false;
	}
	x = Q.elem[Q.front];
	return false;
}